home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / msg.h < prev    next >
C/C++ Source or Header  |  2001-05-12  |  3KB  |  82 lines

  1.  
  2. #ifndef _TEK_MSG_H
  3. #define    _TEK_MSG_H
  4.  
  5. /*
  6. **    tek/msg.h
  7. **
  8. **    message IPC
  9. */
  10.  
  11. #include <tek/exec.h>
  12. #include <tek/util.h>
  13.  
  14.  
  15. typedef struct                    /* message. strictly private */
  16. {
  17.     THNDL handle;                /* object handle for linking to msg queue and memory manager */
  18.     TUINT size;                    /* full size of the msg, including data */
  19.     TUINT status;                /* delivery status */
  20.     TPORT *replyport;            /* msgport to which msg is replied/acknowledged to */
  21.     TAPTR sender;                /* sender object */
  22. }    TMSG;
  23.  
  24.  
  25. /* 
  26. **    msg status.
  27. */
  28.  
  29. #define TMSG_STATUS_UNDEFINED        0x00        /* msg status undefined */
  30. #define TMSG_STATUS_SENT            0x01        /* msg has been sent successfully */
  31. #define TMSG_STATUS_FAILED            0x02        /* msg has not been delivered successfully */
  32. #define TMSG_STATUS_REPLIED            0x03        /* msg successfully returned to the sender */
  33. #define TMSG_STATUS_ACKD            0x04        /* msg successfully acknowledged to the sender */
  34. #define TMSG_STATUS_PENDING            0x10        /* msg is pending in a message port queue */
  35.  
  36.  
  37. /* 
  38. **    msg tags.
  39. **
  40. */
  41.  
  42. #define TMSGTAGS_                    (TTAG_USER + 0x400)
  43. #define TMsg_Size                    (TTAG) (TMSGTAGS_ + 0)        /* size of a message */
  44. #define TMsg_Status                    (TTAG) (TMSGTAGS_ + 1)        /* message delivery status */
  45. #define TMsg_Sender                    (TTAG) (TMSGTAGS_ + 2)        /* message sender symbolic name */
  46. #define TMsg_SenderHost                (TTAG) (TMSGTAGS_ + 3)        /* message sender host name */
  47. #define TMsg_SenderPort                (TTAG) (TMSGTAGS_ + 4)        /* message sender port nr */
  48.  
  49.  
  50. /* 
  51. **    msg allocation support macros.
  52. */
  53.  
  54. #define TTaskAllocMsg(task,size) TMMUAlloc(((TTASK *) (task))->msgmmu, size)
  55. #define TFreeMsg(msg) TMMUFree((((TMSG *) (msg)) - 1)->handle.mmu, msg);
  56.  
  57.  
  58. /* 
  59. **    msg accessor macros.
  60. */
  61.  
  62. #define TGetMsgStatus(msg)    ((((TMSG *) (msg)) - 1)->status)
  63. #define TGetMsgSize(msg)    ((((TMSG *) (msg)) - 1)->size - sizeof(TMSG))
  64.  
  65.  
  66. TBEGIN_C_API
  67.  
  68. extern TVOID TPutMsg(TPORT *msgport, TAPTR msg)                                    __ELATE_QCALL__(("qcall lib/tek/msg/putmsg"));
  69. extern TVOID TPutReplyMsg(TPORT *msgport, TPORT *replyport, TAPTR msg)            __ELATE_QCALL__(("qcall lib/tek/msg/putreplymsg"));
  70. extern TAPTR TGetMsg(TPORT *port)                                                __ELATE_QCALL__(("qcall lib/tek/msg/getmsg"));
  71. extern TVOID TAckMsg(TAPTR msg)                                                    __ELATE_QCALL__(("qcall lib/tek/msg/ackmsg"));
  72. extern TVOID TReplyMsg(TAPTR msg)                                                __ELATE_QCALL__(("qcall lib/tek/msg/replymsg"));
  73. extern TVOID TDropMsg(TAPTR msg)                                                __ELATE_QCALL__(("qcall lib/tek/msg/dropmsg"));
  74. extern TAPTR TSendMsg(TAPTR task, TPORT *msgport, TAPTR msg)                    __ELATE_QCALL__(("qcall lib/tek/msg/sendmsg"));
  75. extern TUINT TGetMsgAttrs(TAPTR mem, TTAGITEM *tags)                            __ELATE_QCALL__(("qcall lib/tek/msg/getmsgattrs"));
  76. extern TSTRPTR TGetMsgSender(TAPTR msg)                                            __ELATE_QCALL__(("qcall lib/tek/msg/getmsgsender"));
  77.  
  78. TEND_C_API
  79.  
  80.  
  81. #endif
  82.